<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
    <div>
        <input type="checkbox" value="1" name="check" checked="checked1" />
        <input type="checkbox" value="2" name="check"  />
        <input type="checkbox" value="3" name="check" checked="checked" />
        <input type="checkbox" value="4" name="check"   />
    </div>
</body>
<script type="text/javascript">
    //遍历checkbox控件，输出选中个数
    var GetCheckBoxNum = function(){
        var arr = new Array();
        var sum=0
        var ckx = document.getElementsByName("check");
        for (var i = 0; i < ckx.length; i++) {
            if(ckx[i].checked==true){
                sum++
            }
        }
        console.log(sum);
    }
    GetCheckBoxNum()
</script>
</html>